{extend name="base" /}
{block name="title"}
<title>编辑栏目</title>
{/block}
{block name="content"}

<fieldset class="layui-elem-field layui-field-title">
    <legend>
        <span class="layui-breadcrumb">
            <a href="{:url('admin/category/index')}">栏目管理</a>
            <a><cite>修改</cite></a>
        </span>
    </legend>
    <br>
    <a href="{:url('admin/category/add')}" class="layui-btn" target="">添加栏目</a>
    <a href="{:url('admin/category/index')}" class="layui-btn layui-btn-normal" target="">栏目列表</a>
</fieldset>
<!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>方框风格的表单集合</legend>
</fieldset>-->

<form class="layui-form layui-form-pane" action="" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">父级栏目</label>

        <div class="layui-input-block">
            <select name="parent_id" lay-filter="parent" id="parent_id">
                <option value="0">==顶级栏目==</option>
                {foreach name="list" item="v"}
                <option value="{$v->id}" {if $v->id == $data->parent_id}selected{/if}>{$v->name}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="require">*</i>栏目名称</label>

        <div class="layui-input-block">
            <input type="text" value="{$data->name}" name="name" lay-verify="name" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="require">*</i>前台地址</label>

        <div class="layui-input-block">
            <input type="text" value="{$data->fore_url}" name="fore_url" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="require"></i>后台地址</label>

        <div class="layui-input-block">
            <input type="text" value="{$data->back_url}" name="back_url" lay-verify="" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <input type="hidden" name="id" value="{$data.id}">
        <button class="layui-btn" lay-submit="" lay-filter="sub">提交</button>
    </div>
</form>
<form class="layui-form layui-form-pane" action="" method="post">
    <table class="layui-table">
        <colayui-inputroup>
            <col width="10%">
            <col width="80%">
            <col width="10%">
        </colayui-inputroup>
        <thead>
        <tr>
            <th class="tc">名称</th>
            <th class="tc">值</th>
            <th class="tc">说明描述</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <th><i class="require">*</i>父级栏目：</th>
            <td>
                <div>
                    <select name="parent_id" lay-filter="parent" id="parent_id">
                        <option value="0">==顶级栏目==</option>
                        {foreach name="list" item="v"}
                        <option value="{$v->id}" {if $v->id == $data->parent_id}selected{/if}>{$v->name}</option>
                        {/foreach}
                    </select>
                </div>
            </td>
        </tr>
        <tr>
            <td class="tc" width="10px"><i class="require">*</i>栏目名称：</td>
            <td>
                <input type="text" value="{$data->name}" name="name" lay-verify="name" placeholder="请输入" autocomplete="off" class="layui-input">
            </td>
        </tr>
        <tr>
            <th><i class="require">*</i>前台地址：</th>
            <td>
                <div style="float:left; width: 30%">
                    <input type="text" value="{$data->fore_url}" name="fore_url" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
                <div style="float: left;"> &nbsp;&nbsp;</div>
            </td>
        </tr>


        <tr id="content">
            <th><i class="require"></i>后台地址：</th>
            <td>
                <input type="text" value="{$data->back_url}" name="back_url" lay-verify="" placeholder="请输入" autocomplete="off" class="layui-input">
                <span></span>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div class="layui-form-item">
                    <input type="hidden" name="id" value="{$data.id}"/>
                    <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                </div>
            </td>
        </tr>

        </tbody>
    </table>
</form>
{/block}
{block name="js"}
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate','element'], function () {
        var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate,element = layui.element;

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            name: function (value) {
                if (value.length < 2) {
                    return '标题至少得2个字符啊';
                }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听提交
        form.on('submit(sub)', function (data) {
            /*layer.alert(JSON.stringify(data.field), {
             title: '最终的提交信息'
             });*/
            return true;
        });

        // you code ...


    });
</script>
{/block}